<template>
<!-- 商品列表页 排序页 -->
  <div class="product-list-sort">
    <!-- 添加点击事件传入对于index 和 acitve 做对比为true时添加class类名 为false时去掉 -->
    <div :class="{'active' : acitve == 1}" @click="flag(1)">
      <span>默认排序</span>
    </div>
    <div :class="{'active' : acitve == 2}" @click="flag(2)">
      <span>升序</span>
      <i class="icon icon-shangjiantou"></i>
    </div>
    <div :class="{'active' : acitve == 3}" @click="flag(3)">
      <span>降序</span>
      <i class="icon icon-xiajiantou"></i>
    </div>
    <div :class="{'active' : acitve == 4}" @click="flag(4)">
      <span>筛选</span>
      <i class="icon icon-shaixuan"></i>
    </div>
  </div>
</template>

<script>
export default {
  data(){
    return {
      acitve:1
    }
  },
  methods:{
    flag(index){
      this.acitve = index
      this.$emit('sortFn',index)
    }
  }
}
</script>

<style scoped>
  .product-list-sort{
    position: fixed;
    top: 100px;
    left: 0;
    width: 100%;
    height: 100px;
    display: flex;
    font-size: 30px;
    align-items: center;
    border-top: 1px solid #dcdcdc;
    border-bottom: 1px solid #dcdcdc;
    background-color: white;
    z-index: 1;
  }
  .product-list-sort>div{
    flex: 25%;
    text-align: center;
  }
  .product-list-sort i{
    font-size: 24px;
    color: rgb(153, 153, 153);
    margin-left: 10px;
  }
  .active{
    color: #f63515;
  }
</style>